const app = getApp();
Page({
  data: {
    is_login:false,
    userInfo:[],
    web_info:app.globalData.web_info,
    jifen:0,
    bill_count:0,
    sign_count:0,
    continuity_day:0,
  },

  onShow:function(){
    this.getUserInfo();
  },

  //积分详情
  jifen_detail:function(){
    wx.navigateTo({
      url: './jifen_detail'
    })
  },

  //获取个人信息
  getUserInfo:function(){
    let _this = this;
    app._post('api/member/getUserInfo', {}, function(result) {
      if(result.code == 200){
        _this.setData({
          is_login:true,
          userInfo:result.data,
          bill_count:result.data.bill_count,
          sign_count:result.data.jifen,
          continuity_day:result.data.continuity_day,
        })
      }else{
        wx.navigateTo({
          url: '/pages/auth/auth'
        })
      }
    });
  },
  
  //退出登陆
  clear_login:function(){
    wx.removeStorageSync('token');
    wx.removeStorageSync('userInfo');
    this.onShow();
  },

  onShareAppMessage() {
    return {
      title: '优倍记账本',
      path: '/pages/index/index'
    }
  },

  //打开新的购物小程序
  to_new_xcx:function(){
    wx.navigateToMiniProgram({
      appId: 'wx6f9c8526a217c251'
    })
  },

  //正在开发中弹窗
  need_dev:function(){
    wx.showToast({
      title: '已纳入开发计划',
      icon: 'none',
      duration: 2000
    })
  },
})